import React, { useState } from 'react';
import { Radio, Row, Col, Button } from 'antd';
import { history } from 'umi';
import { Homework } from '@/pages/login/service';

export default function index(Props: any) {
  const onChange = (e: any) => {
    setvalue(e.target.value);
    if (e.target.value == 'details') {
      history.push({
        pathname: '/global/homework/details',
      });
    } else if (e.target.value == 'answer') {
      history.push({
        pathname: '/global/homework/answer',
      });
    } else if (e.target.value == 'correct') {
      history.push({
        pathname: '/global/homework/correct',
      });
    }
  };
  React.useEffect(() => {}, []);
  const [value, setvalue] = useState(history.location.pathname.slice(17));
  return (
    <>
      <Row style={{ marginTop: 30 }} justify="center">
        <Col span={22}>
          <Radio.Group
            value={value}
            buttonStyle="solid"
            onChange={onChange}
            size="large"
          >
            <Radio.Button value="details">作业任务</Radio.Button>
            <Radio.Button value="answer">学生答题</Radio.Button>
            <Radio.Button
              value="correct"
              disabled={Homework.getHomeworkIds().state == 0}
            >
              老师批复
            </Radio.Button>
          </Radio.Group>
          <Button
            style={{ float: 'right' }}
            onClick={() => {
              history.goBack();
            }}
          >
            返回
          </Button>
        </Col>
        <Col span={21} style={{ marginTop: 60 }}>
          {Props.children}
        </Col>
      </Row>
    </>
  );
}
